<template>
  <view class="box-item" @click="gotoPage">
    <view class="icon-img" v-if="icon">
      <u-image :src="icon" :fade="false" :width="size" :height="size" :showMenuByLongpress="false"></u-image>
    </view>
    <view class="icon-img" v-else></view>
    <view class="label">{{ label }}</view>
  </view>
</template>

<script>
export default{
  name:"BoxItem",
  props:{
    size: {
      type: String,
      default: '2rem'
    },
    icon: {
      type: String,
      default: ''
    },
    label: {
      type: String,
      default: ''
    },
    path: {
      type: String,
      default: ''
    }
  },
  data(){
    return{

    }
  },
  methods:{
    gotoPage() {
      if(this.path) {
        uni.navigateTo({
          url: this.path,
        })
      }
    }
  },
  created(){

  }
}
</script>

<style lang="scss" scoped>
.box-item {
  &:active {
    background: #ECEFF1;
    box-shadow:  0 0 3px #CFD8DC;
    opacity: 0.8;
  }
  color: #212121;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: #fff;
  height: 100%;
  .icon-img {
    max-width: 3rem;
    margin: 1rem 0;
    width: 100%;
    display: flex;
    justify-content: center;
  }
  .label {
    height: 1.5rem;
    line-height: 1.5rem;
    font-size: 1rem;
  }
}
</style>
